<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/header.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户页面</title>
<script type="text/javascript">
function refGrid(){
	$('#datagridtable').datagrid("clearChecked");
	$('#datagridtable').datagrid("options").url='${base}sysUser/userList?'+$("form").serialize();
	$('#datagridtable').datagrid("load");  
}

  $(function(){
	  $("#searchbtn").click(function(){refGrid();});
	  
	  $('#datagridtable').datagrid({    
		    singleSelect:false,
		    collapsible:false,
		    url:'${base}sysUser/userList?'+$("form").serialize(),
		    method:'post',
		    pagination:true,
		    toolbar:'#toolbar',
			pageSize:20,
			multiSort:true,
			rownumbers:true,
			border:false,
			animate:true,
			idField:'id',
			autoRowHeight:false,
			fitColumns: true,
		    columns:[[    
		        {field:'id',checkbox:true},    
		        {field:'userName',title:'姓名',width:80,sortable:true},    
		        {field:'userAccount',title:'系统账号',width:100,sortable:true},
		        {field:'orgAbbr',title:'所属组织',width:100,sortable:true},
		        {field:'deptAbbr',title:'所属部门',width:100,sortable:true},
		        {field:'roleList',title:'已分配角色',width:100,sortable:true},
		        {field:'tel',title:'联系电话',width:100,sortable:true},
		        {field:'email',title:'邮箱地址',width:150,sortable:true},
		        {field:'userStatus',title:'状态',width:80,sortable:true,formatter:function(value,row,index){
			        var data=${SysUserStatus};
			        for(var i=0;i<data.length;i++){
			        	if(data[i].itemValue==value&&data[i].itemValue!='')
				        	return data[i].itemName;  
 				        }
			        }},
		        {field:'remark',title:'描述',width:300,sortable:true}
		    ]]    
		});
    
      $("#addBtn").click(function(){
    	  myDialog({title:"添加用户",src:"${base}sysUser/addPage",width:750,height:350,callBack:refGrid});
      });
      $("#editBtn").click(function(){
    	  var selOpts =$('#datagridtable').treegrid("getChecked");
			if(selOpts.length==0||selOpts.length>1)
				myAlert("错误信息","请选择一条记录！","e");
			else
			  myDialog({title:"编辑用户",src:"${base}sysUser/editPage?id="+selOpts[0].id,width:750,height:350,callBack:refGrid});
      });
	 $("#delBtn").click(function(){
		 var selOpts =$('#datagridtable').datagrid("getChecked");
			if(selOpts.length==0){
				myAlert("错误信息","请选择需要删除的记录！","e");
				return;
				}
			ids=[];
			$.each(selOpts,function(i,v){
				     ids.push(v.id);
				});
			myConfirm("提示信息","确定删除选中的数据吗?",function(r){
                  if(r){
                 	 myAjax({url:"${base}sysUser/delUser",data:{"ids":ids},  
                     	 success:function(data){
                               if(data.error=='0')
                             	      refGrid();
                               else
                             	  myAlert("错误信息",data.msg,"e");   
                     	 }}); 
               }
			});
	   });
	 $("#detailBtn").click(function(){
		 var selOpts =$('#datagridtable').datagrid("getChecked");
			if(selOpts.length==0||selOpts.length>1)
				myAlert("错误信息","请选择一条记录！","e");
			else
			  myDialog({title:"查看用户",src:"${base}sysUser/detailPage?id="+selOpts[0].id,width:750,height:300,
				  callBack:function(){
				  $('#datagridtable').datagrid("clearChecked");}});
	  });
	 $("#resetPwdBtn").click(function(){
		 var selOpts =$('#datagridtable').datagrid("getChecked");
			if(selOpts.length==0||selOpts.length>1)
				myAlert("错误信息","请选择一条记录！","e");
			else
			  myDialog({title:"重置密码",src:"${base}sysUser/resetPwdPage?id="+selOpts[0].id,width:400,height:180,
				  callBack:function(){
				  $('#datagridtable').datagrid("clearChecked");}});
	   });
	 $("#importBtn").click(function(){
		 myDialog({title:"用户信息导入",src:"${base}sysUser/importPage?",width:400,height:200,
			  callBack:function(){
			  $('#datagridtable').datagrid("clearChecked");}});
	  });
	 $("#exportBtn").click(function(){
		 window.location.href="${base}sysUser/export?"+$("form").serialize();
	  });
	 $("#tplBtn").click(function(){
		 window.location.href="${base}sysUser/exportTemplate";
	  });
});
</script>
</head>
<body fit="true">
   <div id="toolbar">
   <div class="toolbar_searchcondition">
   <form class="easyui-form" action="${base}sysUserSet/userList"  method="post">
	  账号: <input class="easyui-textbox" name="params['userAccount']" type="text"/>&nbsp;
	  姓名: <input class="easyui-textbox"  name="params['userName']" type="text"/>&nbsp;
	  组织: <input class="easyui-combotree"  name="params['orgId']" type="text" 
	  data-options='valueField:"itemValue",textField:"itemName",data:${SysOrg},editable:false'/>&nbsp;
	  部门: <input class="easyui-combotree"  name="params['deptId']" type="text"
	     data-options='valueField:"itemValue",textField:"itemName",data:${SysDept},editable:false'/>&nbsp;
	  状态: <input class="easyui-combobox" id="userStatus" name="params['userStatus']" type="text" 
	  data-options='valueField:"itemValue",textField:"itemName",data:${SysUserStatus},editable:false'/>&nbsp;
		   <a href="#" class="easyui-linkbutton searchbtn" iconCls="icon-search" id="searchbtn">查询</a>
		</form>
	 </div>
	 <div class="toolbar_btns">
	        <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="addBtn">添加</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="editBtn">编辑</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="delBtn">删除</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" id="detailBtn">查看</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="resetPwdBtn">重置密码</a>
            <span class="btn-separator" style="display:inline-block;"></span>
			<a href="#" class="easyui-linkbutton" iconCls="icon-data-import" plain="true" id="importBtn">导入</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-data-export" plain="true" id="exportBtn">导出</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-download" plain="true" id="tplBtn">模板</a>
	 </div>	
   </div>
     
	  <table id="datagridtable"  style="width:1200px;height:500px" fit="true"></table>
</body>
</html>